import numpy as np
import matplotlib.pyplot as plt
import os
from matplotlib.colors import LogNorm

# define data directory
fname = 'exfig4b.npz'

# load npz file
data = np.load(fname, allow_pickle=True)
print(data.files)
#save data to variables
for key in data.files:
    exec(key + " = data['" + key + "']")

# plot
fig, ax = plt.subplots(1, 1, figsize=(3.5, 3))
fig.suptitle('exfig4b')
fig.subplots_adjust(bottom=0.2)
fig.subplots_adjust(left=0.2)

im = ax.scatter(n, D, c=delta_R/1e3, rasterized=True, vmin=-0.5,vmax=0.1, cmap='viridis_r',marker='s',s=0.5) 
cbar = fig.colorbar(im, ax=ax)
cbar.set_label('$\Delta R_{yx}$ ($k\Omega$)')
ax.set_xlabel('n (cm$^{-2}$)')
ax.set_ylabel(r'$D/\epsilon_0$ (V/nm)')
plt.show()